/*
 * Jabberd2-json-libs-java  
 * Copyright (C) 2010 Antti Leppä / Foyt
 * http://www.foyt.fi
 * 
 * License: 
 * 
 * Licensed under GNU General Public License Version 3 (GPL) 
 * http://www.gnu.org/licenses/gpl.html
 */

package fi.foyt.jabberd2json;

/**
 * Defines update mode. 
 */
public enum ObjectSetUpdateMode {

  PUT       ("put"),
  REPLACE   ("replace"),
  DELETE    ("delete");
    
  private ObjectSetUpdateMode(String name) {
    this.name = name;
  }
  
  /**
   * Returns update mode's internal name
   * 
   * @return Update mode's internal name
   */
  public String getName() {
    return name;
  }
  
  /**
   * Finds update mode by internal name
   * 
   * @param name Update mode's internal name
   * @return ObjectSetUpdateMode
   */
  public static ObjectSetUpdateMode getByName(String name) {
    for (ObjectSetUpdateMode objectSetUpdateMode : values()) {
      if (objectSetUpdateMode.getName().equals(name))
        return objectSetUpdateMode;
    }
    
    return null;
  }
  
  private String name;
}
